package com.mongo.jdbc;

import java.sql.Connection;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Logger;


/**
 * 
 * @author:binggong
 * @createtime:2019年8月17日 下午5:44:33
 * @version:V.0.1
 * @tag: hbase jdbc Driver
 *
 */
public class Driver implements java.sql.Driver{

	static {
		try {
			java.sql.DriverManager.registerDriver(new Driver());
		} catch (SQLException E) {
			throw new RuntimeException("Can't register driver!");
		}
	}
	
	/**
	 * Construct a new driver and register it with DriverManager
	 * 
	 * @throws SQLException
	 *             if a database error occurs.
	 */
	public Driver() throws SQLException {
		// Required for Class.forName().newInstance()
	}
	
	
	public Connection connect(String url, Properties info) throws SQLException {
		// TODO Auto-generated method stub
		
		
		return com.mongo.jdbc.Connection.getInstance(url, info);
	}

	public boolean acceptsURL(String url) throws SQLException {
		// TODO Auto-generated method stub
		if (url != null && url.toLowerCase().trim().startsWith("jdbc:mongo://")) {
			return true;
		} 
		
		return false;
	}

	public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
			throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	public int getMajorVersion() {
		// TODO Auto-generated method stub
		return 0;
	}

	public int getMinorVersion() {
		// TODO Auto-generated method stub
		return 0;
	}

	public boolean jdbcCompliant() {
		// TODO Auto-generated method stub
		return false;
	}

	public Logger getParentLogger() throws SQLFeatureNotSupportedException {
		// TODO Auto-generated method stub
		return null;
	}

}
